﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace HZ.Supervise.Web.Peculiar
{
    public partial class Lookhistory : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ShowHistor();
            }
        }
        public Lookhistory() 
        {
            this.ModuleNo = "特殊权限";
            this.PageOperateType = "维护";
        }
        private void ShowHistor()
        {

            string id1 = HZ.Common.HzConvert.ToString(Request.QueryString["id1"]);//Hid
            string id2 = HZ.Common.HzConvert.ToString(Request.QueryString["id2"]);//0 医院采购范围，1地区采购药品 ，2地区采购价格
            string id3 = HZ.Common.HzConvert.ToString(Request.QueryString["id3"]);//areaid 地区
            string id4 = HZ.Common.HzConvert.ToString(Request.QueryString["id4"]);//goodsid 流水号
            string hospitalId = HZ.Common.HzConvert.ToString(Request.QueryString["HospitalId"]);

            HZ.Supervise.IBLL.IBLL_SpecialAuthority sp = HZ.Supervise.BLLFactory.IBLL_SpecialAuthority();

            switch (id2)
            {
                case "0"://医院采购范围
                    List<HZ.Supervise.Model.View.HopitalAreaSortSource> list = sp.GetHostory<HZ.Supervise.Model.View.HopitalAreaSortSource>(id1, id2, id3, id4);
                    BoundField bfd = new BoundField();
                    bfd.DataField = "HospitalName";
                    bfd.HeaderText = "医院名称";
                    gvwProduceCatalog.Columns.Add(bfd);
                    BoundField bfd1 = new BoundField();
                    bfd1.DataField = "AreaName";
                    bfd1.HeaderText = "地区";
                    gvwProduceCatalog.Columns.Add(bfd1);
                    BoundField bfd5 = new BoundField();
                    bfd5.DataField = "SortSource";
                    bfd5.HeaderText = "药品类别";
                    gvwProduceCatalog.Columns.Add(bfd5);
                    BoundField bfd4 = new BoundField();
                    bfd4.DataField = "IsUsering";
                    bfd4.HeaderText = "修改状态";
                    gvwProduceCatalog.Columns.Add(bfd4);
                    BoundField bfd2 = new BoundField();
                    bfd2.DataField = "Huserid";
                    bfd2.HeaderText = "修改人";
                    gvwProduceCatalog.Columns.Add(bfd2);
                    BoundField bfd3 = new BoundField();
                    bfd3.DataField = "Hchangetime";
                    bfd3.HeaderText = "修改时间";
                    gvwProduceCatalog.Columns.Add(bfd3);
                    gvwProduceCatalog.DataSource = list;
                    gvwProduceCatalog.DataBind();
                    break;
                case "1"://地区采购药品
                    List<HZ.Supervise.Model.View.ViewAreaDeleteProcure> apricelist = sp.GetHostory<HZ.Supervise.Model.View.ViewAreaDeleteProcure>(id1, id2, id3, id4);
                    BoundField apricebf1 = new BoundField();
                    apricebf1.DataField = "ProcureCatalogID";
                    apricebf1.HeaderText = "流水号";
                    gvwProduceCatalog.Columns.Add(apricebf1);
                    BoundField apricebf2 = new BoundField();
                    apricebf2.DataField = "Arearname";
                    apricebf2.HeaderText = "地区名称";
                    gvwProduceCatalog.Columns.Add(apricebf2);
                    BoundField apricebf3 = new BoundField();
                    apricebf3.DataField = "Isdeleoradd";
                    apricebf3.HeaderText = "调整状态";
                    gvwProduceCatalog.Columns.Add(apricebf3);
                    BoundField apricebf4 = new BoundField();
                    apricebf4.DataField = "Aadduserid";
                    apricebf4.HeaderText = "调整人";
                    gvwProduceCatalog.Columns.Add(apricebf4);
                    BoundField apricebf5 = new BoundField();
                    apricebf5.DataField = "Aaddtime";
                    apricebf5.HeaderText = "调整时间";
                    gvwProduceCatalog.Columns.Add(apricebf5);
                    gvwProduceCatalog.DataSource = apricelist;
                    gvwProduceCatalog.DataBind();
                    break;
                case "2"://地区采购价格
                    List<HZ.Supervise.Model.View.ViewAraepriceLoge> arelist = sp.GetHostory<HZ.Supervise.Model.View.ViewAraepriceLoge>(id1, id2, id3, id4);
                    BoundField arebf1 = new BoundField();
                    arebf1.DataField = "ProcureCatalogID";
                    arebf1.HeaderText = "流水号";
                    gvwProduceCatalog.Columns.Add(arebf1);
                    BoundField arebf2 = new BoundField();
                    arebf2.DataField = "Arearname";
                    arebf2.HeaderText = "地区名称";
                    gvwProduceCatalog.Columns.Add(arebf2);
                    BoundField arebf3 = new BoundField();
                    arebf3.DataField = "Aprice";
                    arebf3.HeaderText = "调整后价格";
                    gvwProduceCatalog.Columns.Add(arebf3);
                    BoundField arebf4 = new BoundField();
                    arebf4.DataField = "oldPrice";
                    arebf4.HeaderText = "原来价格";
                    gvwProduceCatalog.Columns.Add(arebf4);
                    BoundField arebf5 = new BoundField();
                    arebf5.DataField = "Aadduserid";
                    arebf5.HeaderText = "调整人";
                    gvwProduceCatalog.Columns.Add(arebf5);
                    BoundField arebf6 = new BoundField();
                    arebf6.DataField = "Aaddtime";
                    arebf6.HeaderText = "调整时间";
                    gvwProduceCatalog.Columns.Add(arebf6);
                    gvwProduceCatalog.DataSource = arelist;
                    gvwProduceCatalog.DataBind();
                    break;
            }
        }

        protected void gvwProduceCatalog_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                string id2 = HZ.Common.HzConvert.ToString(Request.QueryString["id2"]);

                if (id2.Equals("0"))//只对采购权限 调整显示
                {
                    e.Row.Cells[2].Text = HZ.Supervise.Web.Function.FormatDrugSource(e.Row.Cells[2].Text);
                    if (e.Row.Cells[3].Text == "1")
                    {
                        e.Row.Cells[3].Text = "授权采购";
                    }
                    else
                    {
                        e.Row.Cells[3].Text = "禁止采购";
                    }


                }


            }

        }

    }
}
